import uvicorn
from fastapi import FastAPI

from api.user_api import router as user_router
from api.product_api import router as product_router
from api.order_api import router as order_router
from api.analytics_api import router as analytics_router
from api.ai_assistant_api import router as ai_assistant_router
from database.base import init_db


app = FastAPI()



# 注册API路由
app.include_router(product_router, prefix="/api")
app.include_router(order_router, prefix="/api")
app.include_router(user_router, prefix="/api")
app.include_router(analytics_router, prefix="/api")
app.include_router(ai_assistant_router, prefix="/api")


@app.get("/")
def read_root():
    return {"message": "欢迎使用购物管理系统"}


if __name__ == "__main__":
    # 直接调用初始化数据库函数
    init_db()
    uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)




